Crate risc0_zkvm
source ·Expand description
The RISC Zero zkVM is a RISC-V virtual machine that produces zero-knowledge proofs of code it executes. By using the zkVM, a cryptographic receipt is produced which anyone can verify was produced by the zkVM’s guest code. No additional information about the code execution (such as, for example, the inputs provided) is revealed by publishing the receipt.
In addition to our reference documentation on docs.rs, we have additional (non-reference) resources for using our zkVM that you may also find helpful, especially if you’re new to the RISC Zero zkVM. These include:
- Our Hello World demo – a minimal zkVM application that works out-of-the-box.
- Our zkVM Tutorial, which walks you through writing your first zkVM project.
- The
cargo risczero
tool. It includes anew
command which generates code for building and launching a zkVM guest and guidance on where projects most commonly modify host and guest code. - The examples folder, which contains various examples using our zkVM.
- This clip from our presentation at ZK Hack III gives an overview of the RISC Zero zkVM. Our YouTube channel has many more videos as well.
- We track zkVM issues with known workarounds using the rust guest workarounds GitHub tag. If you’re having problems running your code in the zkVM, you can see if there’s a workaround, and if you’re using a workaround, you can track when it gets resolved to a permanent solution.
- And more on the RISC Zero developer website!
Crate Feature Flags
The following crate feature flags are available.
Note that in order to use risc0-zkvm
in the guest, you must disable the “prove” feature by setting default-features = false
.
Feature | Target(s) | Implies | Description |
---|---|---|---|
cuda | prove, std | Turns on CUDA GPU acceleration for the prover. Requires CUDA toolkit to be installed. | |
metal | macos | prove, std | Turns on Metal GPU acceleration for the prover. |
profiler | all | Tracks where cycles are spent during guest execution as an aid to code optimization. | |
prove | all except rv32im | std | Enables the prover, incompatible within the zkvm guest. |
std | all | Support for the Rust stdlib. |
Modules
- The RISC Zero zkVM’s guest-side RISC-V API.
- Re-exports for recursion
- Serialization and deserialization tools for the RISC Zero zkVM
- SHA-256 hashing services
Macros
- Construct a SyscallName declaration at compile time.
- Used for defining a main entrypoint.
Structs
- A client implementation for interacting with a zkVM server.
- A server implementation for handling requests by clients of the zkVM.
- An implementation of a Prover that runs proof workloads via Bonsai.
- A cheaply cloneable and sliceable chunk of contiguous memory.
- The Executor provides an implementation for the execution phase.
- The crate::Executor is configured from this object.
- A builder pattern used to construct an ExecutorEnv.
- An implementation of a Prover that runs proof workloads via an external
r0vm
process. - A basic implementation of a SegmentRef that saves the segment to a file
- A pair of Hal and CircuitHal.
- Loads data into the zkVM image
- An image of a zkVM guest’s memory
- A RISC Zero program
- Options to configure a Prover.
- A receipt attesting to the execution of a Session.
- Data associated with a receipt which is used for both input and output of global state.
- The execution trace of a portion of a program.
- A receipt attesting to the execution of a Segment.
- A wrapper around
Vec<SegmentReceipt>
. - The execution trace of a program.
- A very basic implementation of a SegmentRef.
- Represents the public state of a segment, needed for continuations and receipt verification.
- Context available to the verification process.
Enums
- Indicates how a Segment or Session’s execution has terminated
- An inner receipt can take the form of a SegmentReceipts collection or a SuccinctReceipt.
- An event traced from the running VM.
Constants
- Merkle root of the RECURSION_CONTROL_IDS
- Size of a zkVM memory page.
- Control ID for Poseidon
Traits
- Connects a zkVM client and server
- A Prover can execute a given MemoryImage or ELF file and produce a Receipt that can be used to verify correct computation.
- A ProverServer can execute a given MemoryImage and produce a Receipt that can be used to verify correct computation.
- A reference to a Segment.
- The Events of Session
Functions
- Align the given address
addr
upwards to alignmentalign
. - Return a default Prover based on environment variables, falling back to a default CPU-based prover.
- Select a ProverServer based on the specified ProverOpts and currently compiled features.
- Returns
true
if dev mode is enabled.
Type Aliases
Result<T, Error>